
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
; MoveFileFolder macro usage
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

===========================
 General usage
===========================

you will need to use the following near the start of your script:

;---------
!include 'FileFunc.nsh'
!insertmacro Locate

Var /GLOBAL switch_overwrite
StrCpy $switch_overwrite 0
!include 'MoveFileFolder.nsh'
;---------

$switch_overwrite is used to control overwriting of existing files.
setting to 0 (default) means only overwrite files if overwriting with a newer copy (last modified date check)
setting to 1 means overwrite reguardless

===========================
 Moving individual files
===========================

!insertmacro MoveFile "$INSTDIR\[path\]source-file" "$INSTDIR\[path\]destination-file"

This allows you to move and/or rename an individual file. If a file already exists at the destination it will only be overwritten if newer than the existing one (if not then this one will just be deleted)! Please note that wildcards are NOT supported, you can only moved/rename a single specific file!

In the following example a file is both moved to a different folder AND renamed:

!insertmacro MoveFile "$INSTDIR\old-folder\old-file-name.txt" "$INSTDIR\new-folder\new-file-name.txt"

============================
 Moving folders
============================

!insertmacro MoveFolder "$INSTDIR\[path\]source-folder[\]" "$INSTDIR\[path\]destination-folder[\]" "file-mask"

This allows you to move stuff from one folder to another. It also allows you to effectively rename a folder. Note that this command includes all sub-folders!

The 'file-mask' allows you to specify what files to move. Normally you should specify *.*, however if you require, you can have more flexibility over what files are moved! The asterix (*) aka wildcard is a special character that represents one or more unknown characters. If you wanted to move all .exe files you might specify *.exe. If you wanted to move all files that begin with the letter 'a' you might specify a*.*.

Lets look at an example. Renaming a folder:

!insertmacro MoveFolder "$INSTDIR\old-folder\" "$INSTDIR\new-folder\" "*.*"

Another example, this time for some reason you want to move only .exe files:

!insertmacro MoveFolder "$INSTDIR\old-folder\" "$INSTDIR\new-folder\" "*.exe"

There are a few notes about using MoveFolder:

   1. There is no way to exclude things (besides the file mask). Anything moved that you didn't want to move you will have to move back!
   2. If all files/sub-folders are moved and the source folder is left empty it will be automatically deleted!
   3. You will loose all empty folders in both the source and destination folders during the move. This is a limitation of the code behind it. You will have to re-create them if you want them!

